package com.example.demo1.controller;

import com.example.demo1.pojo.po.User;
import com.example.demo1.service.TokenService;
import com.example.demo1.util.RedisAPI;
import com.example.demo1.util.ResultUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import redis.clients.jedis.Jedis;
import redis.clients.jedis.JedisPool;

/**
 * Description: 本类用于
 * Created by DWB on 2019/12/26 11:25
 */
@RestController
public class TokenController {
    @Autowired
    private TokenService tokenService;

    @Autowired
    private RedisAPI redisAPI;

    @GetMapping("/token")
    public ResultUtil saveToken(){
        User user=new User();
        user.setId(9);
        user.setUserName("zhaoshis");
        user.setUserCode("2368702155@163.com");
        JedisPool jedisPool=redisAPI.createJedisPool();
        Jedis jedis = jedisPool.getResource();
        jedis.set("StringBuff", tokenService.generatorToken("",user));
        return ResultUtil.success("成功");
    }


}
